package com.inspinia.base.dao.db;

/**
 * 数据类型的管理类
 * Created by veblen on 2017/1/10.
 */
public class DataSourceTypeManager {
    private static final ThreadLocal<DataSources> dataSourceTypes = new ThreadLocal<DataSources>() {
        @Override
        protected DataSources initialValue() {
            return DataSources.MASTER;
        }
    };

    public static DataSources get() {
        return dataSourceTypes.get();
    }

    public static void set(DataSources dataSourceType) {
        dataSourceTypes.set(dataSourceType);
//        System.out.println(Thread.currentThread().getName() + "->" + dataSourceType);
    }

    public static void reset() {
        dataSourceTypes.set(DataSources.MASTER);
    }
}